<template>
    <div>
        <el-card style="border:none !important;border-radius: 12px;box-shadow:none !important">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/userhome' }">个人中心</el-breadcrumb-item>
                <el-breadcrumb-item>
                    <a href="/user_message">消息管理</a>
                </el-breadcrumb-item>
                <el-breadcrumb-item>消息列表</el-breadcrumb-item>
            </el-breadcrumb>
            <div class="tab-nav-bd">
                <span class="title">我的消息</span>
            </div>
        </el-card>
        <div class="mainbox" style="margin-top: 20px;">
            <ul class="tabs-nav">
                <input type="hidden" name="msgType" id="msgType" value="1">
                <li :class="isActive == index ? 'active' : ''" v-for="(item, index) in messageClassArr" :key="index">
                    <a>{{ item.title }}
                        <span :class="unreadCount == 0 ? 'tabs-nav-msgnumber_none'  : 'tabs-nav-msgnumber'" >{{unreadCount}}</span>
                    </a>
                </li>

                <li class="li-right">
                    <!-- <a href="javascript: " class="inp-click inp-click2"><span class="over-text">全选</span></a>
                    <a href="javascript: " class="removeOver"><span></span>删除</a> -->
                    <a href="javascript: " class="jsReadAll">全部已读</a>
                </li>

            </ul>
            <ul class="msg">
                <li>
                    <a  class="msg-all active">
                        全部({{total}})
                    </a>
                    <a class="msg-unread">
                        未读(<span>{{unreadCount}}</span>)
                    </a>
                </li>
                <li class="clearfix js-user-msg  have-read" v-for="(mess,mess_index) in messageArr" :key="mess_index">
                    <span class="span-input span-input2"></span>
                    <div class="msg-icon">
                        <el-icon class="icon" size="25"><ChatDotRound /></el-icon>
                    </div>
                    <i :class="!mess.is_read ? 'msg-dot' : ''"></i>
                    <div class="msg-list-item-text msgId80064922">
                        <p>
                           {{ mess.title }}
                        </p>
                        <span>
                            {{ mess.create_time }} </span>
                    </div>
                </li>

            </ul>
        </div>
    </div>
</template>
<script setup lang="ts">
import { ref,computed } from 'vue';
import { messageClass, messageList } from '../../api/message';
import { ElMessage } from 'element-plus';
const total = ref(0)
const isActive = ref(0)

interface Item {  
  id: number;  
  message_class_id:number;
  content:string;
  title: string;  
  status:number;
  is_read: boolean;  
  create_time:string,
} 
const unreadCount = computed(() => {  
    return messageArr.value.filter(item =>!item.is_read).length;  
}); 
//数据类型读取
const messageClassArr =  ref<any[]>([]);  
messageClass({}).then((res: any) => {
    if (res.code === 1) {
        messageClassArr.value = res.data.list
    }
}).catch((error) => {
    ElMessage.error("获取失败")
})
//消息读取
const messageArr = ref<Item[]>([]);  
    messageList({}).then((res: any) => {
    if (res.code === 1) {
        messageArr.value = res.data.list
        total.value = res.data.total
    }
}).catch((error) => {
    ElMessage.error("获取失败")
})


</script>



<style scoped>
.tab-nav-bd {
    margin-top: 16px;
}

.tab-nav-bd .title {
    font-size: 18px;
    font-weight: 700;
    color: #1D2129;
    line-height: 26px;
}

.mainbox {
    padding: 18px 24px 24px 6px;
    padding-top: 18px;
    padding-right: 24px;
    padding-bottom: 24px;
    padding-left: 6px;
}

.mainbox {
    margin-left: 0;
    width: 100%;
    padding: 20px;
    background-color: #fff;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    border-radius: 10px;
}

.tabs-nav {
    margin: 0 0 16px;
    border-color: #F2F3F5;
    border-bottom: solid 1px #e8e8e8;
    zoom: 1;
}

.tabs-nav li {
    margin: 0 18px;
    padding: 0 0 10px;
    line-height: 1;
}

.tabs-nav li {
    float: left;
    margin: 0 15px -1px 15px;
    line-height: 40px;
    padding: 0 4px;
    border-bottom: solid 2px transparent;
    font-size: 16px;
    color: #666;
}

.tabs-nav li a,
.tabs-nav li span {
    color: #4E5969;
    line-height: 22px;
}

.tabs-nav li a {
    position: relative;
}

.tabs-nav .active {
    color: #e85623;
    border-width: 3px;
    border-color: #e85623;
}

.tabs-nav .li-right {
    float: right;
}

.tabs-nav:after {
    display: block;
    clear: both;
    content: "";
    visibility: hidden;
    height: 0;
}

.msg li:hover {
    background-color: #F2F3F5;
}

.msg li {
    margin-top: 8px;
    padding: 8px 24px;
    border-bottom: none;
}

.msg li .msg-all {
    color: #4E5969;
    line-height: 22px;
}

.msg li .msg-all {
    font-size: 14px;
    color: #999;
}

.msg li .active,
.msg li .active>span {
    color: #e85623;
}

.msg li .msg-unread {
    font-size: 14px;
    color: #999;
    font-weight: bold;
    margin-left: 25px;
}

.tabs-nav .over-input {
    background: #fff;
    border-radius: 50%;
    border: 1px solid #4E5969;
}

.tabs-nav .over-input {
    position: relative;
    top: 2px;
    width: 14px;
    height: 14px;
    margin-right: 10px;
    background-size: 100% 100%;
}

.tabs-nav li a,
.tabs-nav li span {
    color: #4E5969;
    line-height: 22px;
}

.tabs-nav .li-right a {
    margin-left: 20px;
}

.msg .develop-more-msg .msg-list-item-text p {
    white-space: normal;
}

.msg li .msg-list-item-text p {
    margin-bottom: 8px;
    font-size: 16px;
    color: #1D2129;
    line-height: 24px;
}

.msg li .msg-list-item-text span {
    color: #C9CDD4;
    line-height: 24px;
}
.msg li .msg-dot {
    float: left;
    display: block;
    width: 6px;
    height: 6px;
    margin-left: -10px;
    background: #fb3d30;
    border-radius: 50%;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
}
.msg li .msg-icon {
    float: left;
    width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    background: #F2F3F5;
    border-radius: 50%;
}
.msg li div {
    float: left;
    margin-left: 10px;
    width: 85%;
}
.js-more-msg {
    margin-left: 18px;
    font-size: 14px;
    color: #C9CDD4;
    cursor: pointer;
}
.msg-list-item-delete {
    top: 10px;
}
.msg-list-item-delete {
    background: url(https://static.3d66.com/user/images/msg/delete2.png) center no-repeat;
    width: 18px;
    height: 17px;
    position: absolute;
    top: 34px;
    right: 5px;
    display: none;
    cursor: pointer;
}
.clearfix:after {
    display: block;
    clear: both;
    content: "";
    visibility: hidden;
    height: 0;
}
.msg li:hover .msg-list-item-delete {
    display: block;
}
.msg-list-item-delete:hover {
    background: url(https://static.3d66.com/user/images/msg/delete.png) center no-repeat;
}
.msg-list-item-delete {
    top: 10px;
}
.tabs-nav li .tabs-nav-msgnumber {
    position: absolute;
    top: -5px;
    right: -25px;
    padding: 0px 5px;
    display: block;
    height: 16px;
    line-height: 16px;
    font-size: 12px;
    color: #fff;
    background: rgba(236, 53, 53, 1);
    border-radius: 7px 8px 8px 0px;
}

.tabs-nav li .tabs-nav-msgnumber_none {
    position: absolute;
    top: -5px;
    right: -25px;
    padding: 0px 5px;
    display: none;
    height: 16px;
    line-height: 16px;
    font-size: 12px;
    color: #fff;
    background: rgba(236, 53, 53, 1);
    border-radius: 7px 8px 8px 0px;
}
</style>